﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PraxisRent.Entities;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace PraxisRent.Repository.Mapping
{
    public class PERSONAMap:EntityTypeConfiguration<PERSONA>
    {
        public PERSONAMap()
        {
            this.HasKey(t => t.Id);

            this.Property(t => t.Dni)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.ApePaterno)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.ApeMaterno)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Nombres)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Direccion)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.Email)
                .HasMaxLength(50);

            this.ToTable("PERSONA");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Dni).HasColumnName("Dni");
            this.Property(t => t.ApePaterno).HasColumnName("ApePaterno");
            this.Property(t => t.ApeMaterno).HasColumnName("ApeMaterno");
            this.Property(t => t.Nombres).HasColumnName("Nombres");
            this.Property(t => t.Direccion).HasColumnName("Direccion");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.EstadoCivilId).HasColumnName("EstadoCivilId");
            this.Property(t => t.SexoId).HasColumnName("SexoId");

            this.HasRequired(t => t.ESTADO_CIVIL)
                .WithMany(t => t.PERSONAs)
                .HasForeignKey(d => d.EstadoCivilId);
            this.HasRequired(t => t.SEXO)
                .WithMany(t => t.PERSONAs)
                .HasForeignKey(d => d.SexoId);
        }
    }
}
